home *** CD-ROM | disk | FTP | other *** search
/ Australian Personal Computer 2000 July / CD 3 / redhat-6.2.iso / RedHat / instimage / usr / lib / anaconda / iw / fdisk.py < prev    next >
Encoding:
Python Source  |  2000-03-08  |  2.9 KB  |  101 lines

  1. from gtk import *
  2. from iw import *
  3. from gnome.zvt import *
  4. from translate import _
  5. import isys
  6. import os
  7.  
  8. class FDiskWindow (InstallWindow):        
  9.  
  10.     def __init__ (self, ics):
  11.     InstallWindow.__init__ (self, ics)
  12.         ics.setTitle (_("fdisk"))
  13.         ics.readHTML ("fdisk")
  14.  
  15.     def child_died (self, widget, button):
  16.         self.windowContainer.remove (self.windowContainer.children ()[0])
  17.         self.windowContainer.pack_start (self.buttonBox)
  18.         button.set_state (STATE_NORMAL)
  19.         try:
  20.             os.remove ('/tmp/' + self.drive)
  21.         except:
  22.             # XXX fixme
  23.             pass
  24.         self.ics.readHTML ("fdisk")
  25.         self.ics.setPrevEnabled (1)
  26.         self.ics.setNextEnabled (1)
  27. #        self.ics.setHelpEnabled (1)
  28.  
  29.     def getPrev(self):
  30.     self.todo.fstab.rescanPartitions()
  31.  
  32.     def getNext(self):
  33.         from installpath import InstallPathWindow
  34.         if ((not InstallPathWindow.fdisk) or
  35.             (not InstallPathWindow.fdisk.get_active ())):
  36.                return None
  37.  
  38.     self.todo.fstab.rescanPartitions()
  39.  
  40.     return None
  41.  
  42.     def button_clicked (self, widget, drive):
  43.         zvt = ZvtTerm (80, 24)
  44.         zvt.set_del_key_swap(TRUE)
  45.         zvt.connect ("child_died", self.child_died, widget)
  46.         self.drive = drive
  47.  
  48.     # free our fd's to the hard drive -- we have to 
  49.     # fstab.rescanDrives() after this or bad things happen!
  50.         if os.access("/sbin/fdisk", os.X_OK):
  51.             path = "/sbin/fdisk"
  52.         else:
  53.             path = "/usr/sbin/fdisk"
  54.         
  55.     isys.makeDevInode(drive, '/tmp/' + drive)
  56.  
  57.  
  58.         if zvt.forkpty() == 0:
  59.             lang = self.ics.getICW().locale
  60.             env = os.environ
  61.             if lang[:2] == "ja":
  62.                 env["LC_ALL"] = "C"
  63.                 env["LANG"] = "C"
  64.             os.execve (path, (path, '/tmp/' + drive), env)
  65.         zvt.show ()
  66.  
  67.         self.windowContainer.remove (self.buttonBox)
  68.         self.windowContainer.pack_start (zvt)
  69.  
  70. #        self.ics.setHelpEnabled (0)
  71.         self.ics.readHTML ("fdiskpart")
  72.     self.ics.setPrevEnabled (0)
  73.         self.ics.setNextEnabled (0)
  74.  
  75.     def getScreen (self):
  76.         from installpath import InstallPathWindow
  77.         if ((not InstallPathWindow.fdisk) or
  78.             (not InstallPathWindow.fdisk.get_active ())):
  79.                return None
  80.  
  81.     self.todo.fstab.closeDrives()
  82.  
  83.         self.windowContainer = GtkVBox (FALSE)
  84.         self.buttonBox = GtkVBox (FALSE, 5)
  85.         self.buttonBox.set_border_width (5)
  86.         box = GtkVButtonBox ()
  87.         label = GtkLabel (_("Select drive to run fdisk on"))
  88.  
  89.         for drive in self.todo.fstab.driveList():
  90.             button = GtkButton (drive)
  91.             button.connect ("clicked", self.button_clicked, drive)
  92.             box.add (button)
  93.  
  94.         self.buttonBox.pack_start (label, FALSE)
  95.         self.buttonBox.pack_start (box, FALSE)
  96.         self.windowContainer.pack_start (self.buttonBox)
  97.  
  98.         self.ics.setNextEnabled (1)
  99.  
  100.         return self.windowContainer
  101.